package com.smartscreen.grademanage.controller;

import com.smartscreen.common.response.ApiResponse;
import com.smartscreen.grademanage.dto.GenerateReportRequest;
import com.smartscreen.grademanage.dto.GenerateReportResponse;
import com.smartscreen.grademanage.entity.LearningReport;
import com.smartscreen.grademanage.service.LearningReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/grade")
public class LearningReportController {
    
    @Autowired
    private LearningReportService learningReportService;
    
    /**
     * 请求生成学习报告 (异步)
     */
    @PostMapping("/students/{studentId}/learning-reports")
    public ApiResponse<GenerateReportResponse> generateReport(
            @PathVariable String studentId,
            @RequestBody GenerateReportRequest request) {
        GenerateReportResponse response = learningReportService.generateReport(studentId, request);
        return new ApiResponse<>(202, "报告生成任务已接受", response);
    }
    
    /**
     * 获取学习报告结果
     */
    @GetMapping("/learning-reports/{reportId}")
    public ApiResponse<LearningReport> getReport(@PathVariable String reportId) {
        LearningReport report = learningReportService.getReport(reportId);
        return ApiResponse.success(report);
    }
}